# -*- coding:utf-8 -*-
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *

class BasicFlowSettingDialog(QDialog):
    picPath = "./com/mat/rpa/views/workWindow/images/"
    def __init__(self, title, parent=None):
        super(BasicFlowSettingDialog, self).__init__(parent)
        #设置最小尺寸
        self.setMinimumSize(1000,600)
        __font = QFont()
        __font.setPixelSize(20)
        __font.setFamily("黑体")
        __font.setBold(True)
        #设置标题
        self.setWindowTitle(title)
        #设置布局
        self.entireLayout = QVBoxLayout()
        self.setLayout(self.entireLayout)
        self.entireLayout.setContentsMargins(20,20,20,20)
        self.entireLayout.setSpacing(10)
        #第一行布局
        self.firstLineLayout = QGridLayout()
        self.firstLineLayout.setContentsMargins(0,0,0,0)
        self.firstLineLayout.setSpacing(5)
        self.imageLabel = QLabel()#默认没有设置图片，根据不同指令设置不同图片
        self.imageLabel.setPixmap(QPixmap(BasicFlowSettingDialog.picPath+"openWebPageBig.png"))
        self.firstLineLayout.addWidget(self.imageLabel, 0,0,2,1, Qt.AlignLeft)
        self.titleLabel = QLabel()#填写标题
        self.titleLabel.setText(title)
        self.firstLineLayout.addWidget(self.titleLabel, 0, 1, 1, 1, Qt.AlignLeft)
        self.infoLabel = QLabel()  #填写提示信息
        self.infoLabel.setText("111111111111111")
        self.firstLineLayout.addWidget(self.infoLabel, 1, 1, 1, 1, Qt.AlignLeft)
        self.questionBtn = QPushButton()
        self.questionBtn.setIcon(QIcon(QPixmap(BasicFlowSettingDialog.picPath+"question.png")))
        self.questionBtn.setText("使用说明")
        self.questionBtn.setStyleSheet("border:None; color:#4e6ef2;")
        self.questionBtn.clicked.connect(self.handleQuestionBtnClicked)
        self.firstLineLayout.addWidget(self.questionBtn, 0, 2, 1, 1, Qt.AlignRight)
        self.firstLineLayout.setColumnStretch(0, 2)  # 设置gridlayout拉伸时，第一列占拉伸比例2/100
        self.firstLineLayout.setColumnStretch(1, 90)  # 而第二列占90/100
        self.firstLineLayout.setColumnStretch(2, 8)  # 而第三列占8/100
        self.entireLayout.addLayout(self.firstLineLayout)
        #第二行，tabWidget
        self.settingTabeWidget = QTabWidget()
        self.regularTab = QWidget()
        self.regularTabLayout = QVBoxLayout()
        self.regularTab.setLayout(self.regularTabLayout)
        self.regularTabLayout.setContentsMargins(0,20,0,0)
        self.regularTabLayout.setSpacing(10)
        ##第一条横线
        inputOfDirectiveLineLayout = QHBoxLayout()
        inputOfDirectiveLineLayout.setContentsMargins(10,10,10,10)
        inputOfDirectiveLineLayout.setSpacing(0)
        inputOfDirectiveLine_firstShortLine = QFrame()
        inputOfDirectiveLine_firstShortLine.setFrameShape(QFrame.HLine)
        inputOfDirectiveLine_firstShortLine.setFrameShadow(QFrame.Sunken)
        inputOfDirectiveLine_firstShortLine.setObjectName("inputOfDirectiveLine_firstShortLine")
        inputOfDirectiveLineLayout.addWidget(inputOfDirectiveLine_firstShortLine, 1)
        inputOfDirectiveLine_info_label = QLabel()
        inputOfDirectiveLine_info_label.setText("指令输入")
        inputOfDirectiveLine_info_label.setFont(__font)
        inputOfDirectiveLineLayout.addWidget(inputOfDirectiveLine_info_label, 1)
        inputOfDirectiveLine_secondLongLine = QFrame()
        inputOfDirectiveLine_secondLongLine.setFrameShape(QFrame.HLine)
        inputOfDirectiveLine_secondLongLine.setFrameShadow(QFrame.Sunken)
        inputOfDirectiveLine_secondLongLine.setObjectName("inputOfDirectiveLine_secondLongLine")
        inputOfDirectiveLineLayout.addWidget(inputOfDirectiveLine_secondLongLine, 8)
        self.regularTabLayout.addLayout(inputOfDirectiveLineLayout)
        ##指令输入设置区域
        self.directiveInputSettingPanel = QWidget()
        self.regularTabLayout.addWidget(self.directiveInputSettingPanel)
        # ##指令输出线
        outputOfDirectiveLineLayout = QHBoxLayout()
        outputOfDirectiveLineLayout.setContentsMargins(10, 10, 10, 10)
        outputOfDirectiveLineLayout.setSpacing(0)
        outputOfDirectiveLine_firstShortLine = QFrame()
        outputOfDirectiveLine_firstShortLine.setFrameShape(QFrame.HLine)
        outputOfDirectiveLine_firstShortLine.setFrameShadow(QFrame.Sunken)
        outputOfDirectiveLine_firstShortLine.setObjectName("outputOfDirectiveLine_firstShortLine")
        outputOfDirectiveLineLayout.addWidget(outputOfDirectiveLine_firstShortLine, 1)
        outputOfDirectiveLine_info_label = QLabel()
        outputOfDirectiveLine_info_label.setText("指令输出")
        outputOfDirectiveLine_info_label.setFont(__font)
        outputOfDirectiveLineLayout.addWidget(outputOfDirectiveLine_info_label, 1)
        outputOfDirectiveLine_secondLongLine = QFrame()
        outputOfDirectiveLine_secondLongLine.setFrameShape(QFrame.HLine)
        outputOfDirectiveLine_secondLongLine.setFrameShadow(QFrame.Sunken)
        outputOfDirectiveLine_secondLongLine.setObjectName("outputOfDirectiveLine_secondLongLine")
        outputOfDirectiveLineLayout.addWidget(outputOfDirectiveLine_secondLongLine, 8)
        self.regularTabLayout.addLayout(outputOfDirectiveLineLayout)
        ##指令输出设置区域
        self.directiveOutputSettingPanel = QWidget()
        self.regularTabLayout.addWidget(self.directiveOutputSettingPanel)
        ##添加常规Tab
        self.settingTabeWidget.addTab(self.regularTab, "常规")
        self.entireLayout.addWidget(self.settingTabeWidget)
        #第三行,按钮
        self.thirdLineLayout = QHBoxLayout()
        self.thirdLineLayout.setContentsMargins(0,0,0,0)
        self.thirdLineLayout.setSpacing(5)
        self.executionButton = QPushButton()
        self.executionButton.setText("运行指令")
        self.executionButton.clicked.connect(self.handleExecutionBtnClicked)
        self.thirdLineLayout.addWidget(self.executionButton)
        self.thirdLineLayout.addStretch(1)
        self.confirmButton = QPushButton()
        self.confirmButton.setText("确定")
        self.confirmButton.clicked.connect(self.handleConfirmBtnClicked)
        self.confirmButton.setObjectName("BasicFlowSettingDialog_confirmBtn")
        self.confirmButton.setStyleSheet('''
            #BasicFlowSettingDialog_confirmBtn {
                background-color: red
            }
        ''')
        self.thirdLineLayout.addWidget(self.confirmButton)
        self.cancelButton = QPushButton()
        self.cancelButton.setText("取消")
        self.cancelButton.clicked.connect(self.handleCancelBtnClicked)
        self.thirdLineLayout.addWidget(self.cancelButton)
        self.entireLayout.addLayout(self.thirdLineLayout)

    def handleQuestionBtnClicked(self):
        print("点击了使用说明按钮")

    def handleExecutionBtnClicked(self):
        print("点击了执行按钮")

    def handleConfirmBtnClicked(self):
        print("点击了确认按钮")

    def handleCancelBtnClicked(self):
        print("点击了取消按钮")

    def setInfoLabelText(self, infoText):
        self.infoLabel.setText(infoText)

    def changeImage(self, imagePath):
        self.imageLabel.setPixmap(QPixmap(imagePath))







